//go:build wireinject

package wire

import (
	"go-server-demo/internal/config"
	"go-server-demo/internal/handler"
	"go-server-demo/internal/repository"
	"go-server-demo/internal/service"
	"go-server-demo/pkg/database"
	redisClient "go-server-demo/pkg/redis"

	"github.com/gin-gonic/gin"
	"github.com/google/wire"
)

// ProviderSet is the wire provider set
var ProviderSet = wire.NewSet(
	config.LoadConfig,
	database.NewEntClient,
	redisClient.NewRedisClient,
	repository.NewUserRepository,
	service.NewUserService,
	handler.NewUserHandler,
	NewApp,
)

func NewApp(userHandler *handler.UserHandler) *gin.Engine {
	gin.SetMode(gin.ReleaseMode)
	r := gin.Default()

	// 注册用户路由
	userHandler.RegisterRoutes(r)

	return r
}

func InitializeApp() (*gin.Engine, error) {
	wire.Build(ProviderSet)
	return &gin.Engine{}, nil
}
